<!-- @author Shiyn/   huangmx 20200807优化-->
<template>
    <div class="top-right-btn">
        <el-row>
            <slot name="prefix"></slot>
<!--            <el-tooltip v-if="sksConfig.isManageMode&&showJumpToEditSksAppConfig" class="item" effect="dark" content="配置表结构" placement="top">-->
<!--                <el-button :disabled="false" size="mini" circle icon="el-icon-s-tools" @click="jumpToEditSksAppConfig" />-->
<!--            </el-tooltip>-->
            <el-tooltip v-if="showSearchButton" class="item" effect="dark" :content="showSearch ? '隐藏搜索' : '显示搜索'" placement="top">
                <el-button :disabled="false"  size="mini" circle icon="el-icon-search" @click="toggleSearch()" />
            </el-tooltip>
            <el-tooltip v-if="showRefreshButton" class="item" effect="dark" content="刷新" placement="top">
                <el-button :disabled="false"  size="mini" circle icon="el-icon-refresh" @click="refresh()" />
            </el-tooltip>
            <el-tooltip v-if="showAllColumnButton" class="item" effect="dark" :content="showAllColumn ? '隐藏多余列' : '显示所有列'" placement="top">
                <el-button :disabled="false"  size="mini" :type="showAllColumn?'success':'info'" circle icon="el-icon-menu" @click="handleChangeShowAllColumn" />
            </el-tooltip>
            <el-tooltip v-if="sksConfig.isDevelopMode&&showTablePropNameButton" class="item" effect="dark" :content="showTablePropName ? '隐藏属性名' : '显示属性名'" placement="top">
                <el-button :disabled="false"  size="mini" :type="showTablePropName?'success':'info'" circle icon="el-icon-s-flag" @click="handleChangeShowTablePropName" />
            </el-tooltip>
        </el-row>
    </div>
</template>
<script>

export default {
    name: "SksRightToolbar",
    props: {
        mainTable:[Object],
        showRefreshButton:{
            type: Boolean,
            default: true,
        },
        showSearchButton:{
            type: Boolean,
            default: true,
        },
        showSearch: {
            type: Boolean,
            default: true,
        },
        showAllColumnButton:{
            type: Boolean,
            default: false,
        },
        showTablePropNameButton:{
            type: Boolean,
            default: true,
        },
        showAllColumn:{
            type: Boolean,
            default: false,
        },
        showTablePropName: false,
    },
    data(){
        return {
            showJumpToEditSksAppConfig: false,

        }
    },
    watch:{
        mainTable:{
            handler(val){
                this.showJumpToEditSksAppConfig=this.mainTable?.mainSksApp?true:false
            },
            immediate: true,
            deep: true,
        }
    },
    methods: {
        //搜索
        toggleSearch() {
            this.$emit("update:showSearch", !this.showSearch);
        },
        //刷新
        refresh() {
            this.$emit("queryTable");
        },
        handleChangeShowTablePropName(){
            this.$emit("update:showTablePropName", !this.showTablePropName);
        },
        handleChangeShowAllColumn(){
            this.$emit("update:showAllColumn", !this.showAllColumn);

            //table 用于触发重新渲染table
            this.$emit("update:showTable", false);
            setTimeout(()=>{
                this.$emit("update:showTable", true);
            },100)
        },
        // jumpToEditSksAppConfig(){
        //     if(this.mainTable?.mainSksApp?.sksAppId){
        //         this.jumpSksAppConfig(this.mainTable.mainSksApp.sksAppId)
        //     }
        // },
    },
};
</script>
